#include"CEntity.h"

CEntity::CEntity(INT iArrX,INT iArrY,LPDIRECT3DTEXTURE9 lpTexture,LPDIRECT3DTEXTURE9 m_lpShadow):m_iArrX(iArrX),m_iArrY(iArrY),m_lpTexture(lpTexture)
	,m_lpShadow(m_lpShadow)
{
	this->UpdateRect();
}

CEntity::~CEntity()
{

}

VOID CEntity::UpdateRect()
{
	m_rect.left = m_iArrY * OBSWIDTH;
	m_rect.top = m_iArrX  * OBSWIDTH;
	m_rect.right = m_rect.left + OBSWIDTH;
	m_rect.bottom = m_rect.top + OBSWIDTH;
}

VOID CEntity::Draw(LPD3DXSPRITE lpSprite)
{
}

VOID CEntity::DrawShadow(LPD3DXSPRITE lpSprite)
{
	static D3DXVECTOR3 d;
	d.x = (FLOAT)(m_iArrY * OBSWIDTH - 5);
	d.y = (FLOAT)(m_rect.top);
	d.z = 0;
	lpSprite->Draw(this->m_lpShadow,NULL,NULL,&d,D3DCOLOR_XRGB(255,255,255));
}

RECT* CEntity::GetRect()
{
	return &m_rect;
}

INT CEntity::GetArrX()
{
	return m_iArrX;
}
INT CEntity::GetArrY()
{
	return m_iArrY;
}

//CStone class
CStone::CStone(INT iArrX,INT iArrY,LPDIRECT3DTEXTURE9 lpTexture,LPDIRECT3DTEXTURE9 m_lpShadow):CEntity(iArrX,iArrY,lpTexture,m_lpShadow)
{

}
CStone::~CStone()
{

}

VOID CStone::Draw(LPD3DXSPRITE lpSprite)
{
	CEntity::Draw(lpSprite);
	static D3DXVECTOR3 p;
	p.x = (FLOAT)(m_iArrY * STONEWIDTH);
	p.y = (FLOAT)(m_rect.bottom - STONEHEIGHT);
	p.z = 0;
	lpSprite->Draw(this->m_lpTexture,NULL,NULL,&p,D3DCOLOR_XRGB(255,255,255));
}

//Box class
CBox::CBox(INT iArrX,INT iArrY,LPDIRECT3DTEXTURE9 lpTexture,LPDIRECT3DTEXTURE9 m_lpShadow):CEntity(iArrX,iArrY,lpTexture,m_lpShadow)
{

}
CBox::~CBox()
{

}

VOID CBox::Draw(LPD3DXSPRITE lpSprite)
{
	CEntity::Draw(lpSprite);
	static D3DXVECTOR3 p;
	p.x = (FLOAT)(m_iArrY * BOXWIDTH);
	p.y = (FLOAT)(m_rect.bottom - BOXHEIGHT);
	p.z = 0;
	lpSprite->Draw(this->m_lpTexture,NULL,NULL,&p,D3DCOLOR_XRGB(255,255,255));
}

//House class
CHouse::CHouse(INT iArrX,INT iArrY,LPDIRECT3DTEXTURE9 lpTexture,LPDIRECT3DTEXTURE9 m_lpShadow):CEntity(iArrX,iArrY,lpTexture,m_lpShadow)
{

}
CHouse::~CHouse()
{

}

VOID CHouse::Draw(LPD3DXSPRITE lpSprite)
{
	CEntity::Draw(lpSprite);
	static D3DXVECTOR3 p;
	p.x = (FLOAT)(m_iArrY * HOUSEWIDTH);
	p.y = (FLOAT)(m_rect.bottom - HOUSEHEIGHT);
	p.z = 0;
	lpSprite->Draw(this->m_lpTexture,NULL,NULL,&p,D3DCOLOR_XRGB(255,255,255));
}

//Block class
CBlock::CBlock(INT iArrX,INT iArrY,LPDIRECT3DTEXTURE9 lpTexture,LPDIRECT3DTEXTURE9 m_lpShadow):CEntity(iArrX,iArrY,lpTexture,m_lpShadow)
{

}
CBlock::~CBlock()
{

}

VOID CBlock::Draw(LPD3DXSPRITE lpSprite)
{
	CEntity::Draw(lpSprite);
	static D3DXVECTOR3 p;
	p.x = (FLOAT)(m_iArrY * BLOCKWIDTH);
	p.y = (FLOAT)(m_rect.bottom - BLOCKHEIGHT);
	p.z = 0;
	lpSprite->Draw(this->m_lpTexture,NULL,NULL,&p,D3DCOLOR_XRGB(255,255,255));
}